//
//  HomeViewController.m
//  ACE
//
//  Created by Mickey Yin on 2021/12/1.
//

#import "HomeViewController.h"
#import "YLJWkWebViewController.h"
#import "KKPaddingLabel.h"

@interface HomeViewController ()

@end

@implementation HomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
//    self.view.backgroundColor = [UIColor colorWithHex:0X017F40 alpha:0.5];
    self.view.backgroundColor = kColorWithHexWithTransparent(0X017F40, 1);
    
    self.navigationItem.title = @"首页";
    
    //m~n之间的随机数
//    int x = arc4random()%(2-0+1)+0;
   
//    NSString *m3 = [YLJTools getTimestampWithDate:@"1647925814"];
//    NSLog(@"xxx-333-- %@", m3);
//
//    NSString *m7 = [YLJTools getTimestampFromTime:@"1647925814"];
//    NSLog(@"xxx-777-- %@", m7);
//
//    NSString *m9 = [YLJTools jxbGetTimestamp:@"1647925814"];
//    NSLog(@"xxx-999-- %@", m9);
//
//    NSString *m0 = [YLJTools textDateToDayStr];
//    NSLog(@"xxx-000-- %@", m0);
    
   
//    NSString *soundPath = [[NSBundle mainBundle]pathForResource:@"shouye" ofType:@"mp3"];
//    NSURL *soundUrl = [NSURL fileURLWithPath:soundPath];
//    //初始化播放器对象
//    AVAudioPlayer *audioPlay = [[AVAudioPlayer alloc]initWithContentsOfURL:soundUrl error:nil];
//    //设置声音的大小
//    audioPlay.volume = 0.5;//范围为（0到1）；
//    //设置循环次数，如果为负数，就是无限循环
//    audioPlay.numberOfLoops = 1;
//    //设置播放进度
//    audioPlay.currentTime = 0;
//
////    audioPlay.delegate = self;
//
//    //准备播放
//    [audioPlay prepareToPlay];
//    [audioPlay play];
    
    
//        NSURL *fileUrl = [[NSBundle mainBundle] URLForResource:@"cunkuan" withExtension:@"mp3"];
//        AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:fileUrl error:nil];
//        if (player) {
//            [player prepareToPlay];
//        }
//
//        [player play];

//    [self playerVoice];
    [self paddingText];
}

- (void)playerVoice
{
    /* 获取本地文件 */
    NSBundle *bundle = [NSBundle mainBundle];
    NSString *urlString = [bundle pathForResource:@"cunkuan" ofType:@"mp3"];
    /* 初始化url */
    NSURL *url = [[NSURL alloc] initFileURLWithPath:urlString];
    /* 初始化音频文件 */
    self.player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];
    /* 加载缓冲 */
    [self.player prepareToPlay];
    [self.player play];
}

- (void)yourMethod:(NSNotification *)notify{
    NSDictionary *dic = notify.userInfo;
    NSLog(@"xxx--- %@", dic[@"1"]);
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    
//    YLJWkWebViewController *wkView = [[YLJWkWebViewController alloc] init];
//    wkView.titleName = @"用户协议";
//    [self.navigationController pushViewController:wkView animated:YES];
    
//    JXBTakePictureController *wkView = [[JXBTakePictureController alloc] init];
//    wkView.modalPresentationStyle = UIModalPresentationFullScreen;
//    [self presentViewController:wkView animated:YES completion:nil];
    
//    JXBCameraSystemViewController *wkView = [[JXBCameraSystemViewController alloc] init];
//    wkView.modalPresentationStyle = UIModalPresentationFullScreen;
//    [self presentViewController:wkView animated:YES completion:nil];
//    [self.navigationController pushViewController:wkView animated:YES];
    
    [self shareTextToWechat];
}

-(void)shareTextToWechat {

//    NSString*text =@"社会化组件U-Share将各大社交平台接入您的应用，快速武装App。";
//    UMSocialMessageObject*messageObject =[UMSocialMessageObject messageObject];
//    messageObject.text = text;
//    [[UMSocialManager defaultManager] shareToPlatform:UMSocialPlatformType_WechatSession messageObject:messageObject currentViewController:self completion:^(id data,NSError*error){
//    NSString*message =nil;
//        if(!error){
//            message =[NSString stringWithFormat:@"分享成功"];
//        }else{
//            message =[NSString stringWithFormat:@"失败原因Code: %d\n",(int)error.code];
//        }
//
//        NSLog(@"分享--- %@", message);
//
//    }];
    
    
}

- (void)paddingText {
    
    KKPaddingLabel *paddingLabel = [[KKPaddingLabel alloc] initWithFrame:CGRectZero];
    paddingLabel.text = @"paddingLabel";
    paddingLabel.backgroundColor = [UIColor orangeColor];
    paddingLabel.padding = UIEdgeInsetsMake(10, 30, 10, 30);
    paddingLabel.cornerRadius = 5.0f;
    paddingLabel.translatesAutoresizingMaskIntoConstraints = NO;
    [self.view addSubview:paddingLabel];
    
    [self.view addConstraint:[NSLayoutConstraint constraintWithItem:paddingLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:200.0f]];
    [self.view addConstraint:[NSLayoutConstraint constraintWithItem:paddingLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:100.0f]];
    
    [paddingLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).with.offset(200);
        make.left.equalTo(self.view).with.offset(100);
    }];
}

@end
